package smallerNumbersThanCurrent;

import java.util.Arrays;

public class Solution {
    public int[] smallerNumbersThanCurrent(int[] nums) {
        int[]arr = new int[101];
        for (int i = 0; i < nums.length; i++) {
            arr[nums[i]]++;
        }
        int[] sum = new int[101];
        sum[0] = arr[0];
        for (int i = 1; i <100 ; i++) {
            sum[i] = sum[i-1]+arr[i];
        }
        for (int i = 0; i < nums.length; i++) {
            nums[i] = nums[i]==0?nums[i]:sum[nums[i]-1];
        }
        return nums;
    }
}
